package org.example.Thread;


public class AutomicVolalite {
    public static void main(String[] args) {
        Test1 test1 = new Test1();
        for(int i=0;i<10;i++){
            new Thread(()->{
                //synchronized (test1) {
                    for (int j = 0; j < 10; j++) {
                        test1.add();
                    }
                //}
                test1.print();
            }).start();
        }
    }
}
class Test1{
    private volatile int x = 0;
    public void add(){
        ++x;
    }
    public void print(){
        System.out.println(x);
    }
}
